package com.kevin.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Classname MYWebConfig
 * @Description 拓展SpringMvc
 * @Date 2020/6/24 16:09
 * @Created by kevin
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");
    }

    /**
     * 将自定义的国际话放置到Spring的容器中
     * @return
     */
    @Bean
    public LocaleResolver localResolver() {
        return new MyLocaleResolver();
    }
}
